Skip to content

pathProxy.ts: Implement --proxy-path-passthrough #2563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 20, 2021

Conversation

nhooyr
Copy link
Contributor

@nhooyr nhooyr commented Jan 11, 2021

Closes #2222

@nhooyr nhooyr requested a review from jsjoeio January 11, 2021 18:28
@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 11, 2021

Even with all of this it doesn't work perfectly...

the sockjs-node connection from webpack doesn't use create-react-app's homepage and so is still absolute. I think I'll implement this and also the Referrer solution I referred to in #2222. It's the only way. Very unfortunate.

Copy link
Contributor

@jsjoeio jsjoeio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Great work 🎉

Do we want to write tests for this?

@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 11, 2021

I tested locally (following the docs) and it works! 🌮

4A6EEDD7-5497-4F55-90CD-34A4ED91CFA2

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 11, 2021

Unfortunately Referrer isn't set on websocket requests and not always set in general so not something we can rely on. create-react-app will have to fix that to have webpack-dev-server properly work through our proxy. Super unfortunate.

@nhooyr nhooyr force-pushed the proxy-path-passthrough-0bb9 branch 2 times, most recently from 920d914 to 4ff5443 Compare January 11, 2021 19:37
@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 11, 2021

Unfortunately Referrer isn't set on websocket requests and not always set in general so not something we can rely on. create-react-app will have to fix that to have webpack-dev-server properly work through our proxy. Super unfortunate.

Do you plan to open up an issue on the create-react-app? (If there isn’t one already)

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 12, 2021

@jsjoeio yup see #2565!

also remember don't review until your review is requested again to avoid reviewing WIP changes.
I still have to write the test you requested.

@nhooyr nhooyr marked this pull request as draft January 12, 2021 15:33
@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 12, 2021

I also converted back to a draft, didn't know I could do that.

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 14, 2021

Tests nearly done! but there's some bizarre fd leak somewhere I need to fix still :(

@nhooyr nhooyr force-pushed the proxy-path-passthrough-0bb9 branch from e026aee to bf97d37 Compare January 14, 2021 23:13
@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 18, 2021

This should be good now @jsjoeio!

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 18, 2021

omg, i see now, it was leaked-handles. confusing me! updating the commit message.

@nhooyr nhooyr marked this pull request as ready for review January 18, 2021 15:46
@nhooyr nhooyr force-pushed the proxy-path-passthrough-0bb9 branch from b591fa0 to 5723c7a Compare January 18, 2021 15:46
@nhooyr nhooyr requested review from jsjoeio and code-asher January 18, 2021 15:46
@nhooyr nhooyr added this to the v3.8.1 milestone Jan 18, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented Jan 19, 2021

@nhooyr great work and great tests! Left one minor nit/question about an any TS type but non-blocking.

Is this PR intentionally fixing other issues? I see stuff related the the dark mode favicon and the heartbeat error that looks like you fixed. Just wanted to make sure! Otherwise, I can approve

@code-asher
Copy link
Member

Wooo this is fabulous; the tests are 🔥

For some history on leaked-handles: if I recall correctly I had issues with code-server or one of the child processes not being killed with a SIGTERM or something due to the socket hanging open, I think. So I added this, tracked down the leaked handles, and it resolved the issue.

Or actually it might have been keeping the tests themselves from finishing? I don't quite recall. Something was hanging somewhere.

With all that said I feel a little more confident if it stayed in but I don't feel super strongly either way.

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

Is this PR intentionally fixing other issues? I see stuff related the the dark mode favicon and the heartbeat error that looks like you fixed. Just wanted to make sure! Otherwise, I can approve

Yea I screwed up this branch somehow. The favicon commits are unrelated but see my comment re the heartbeat changes.

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

With all that said I feel a little more confident if it stayed in but I don't feel super strongly either way.

Happy to leave it in if we can modify the message to indicate it's from that package. Otherwise, it's just confusing if the leak is elsewhere.

And the concerns surrounding it.

Closes #2485
express requires all 4 arguments to be declared for a error handler.
It's very unfortunate that our types do not handle this.
The goal is to remove supertest as it does not support typescript well
and there's really no good reason for the dependency. Also no websocket
testing support.
This had me very confused for quite a while until I did a binary search
inspection on route/index.ts. Only with the heart.beat line commented
out did my tests pass without leaking.

They weren't leaking fds but just this heartbeat timer and node of
course prints just fds that are active when it detects some sort of leak
I guess and that made the whole thing very confusing. These fds are not
leaked and will close when node's event loop detects there are no more
callbacks to run.

no of handles 3

tcp stream {
  fd: 20,
  readable: false,
  writable: true,
  address: {},
  serverAddr: null
}

tcp stream {
  fd: 22,
  readable: false,
  writable: true,
  address: {},
  serverAddr: null
}

tcp stream {
  fd: 23,
  readable: true,
  writable: false,
  address: {},
  serverAddr: null
}

It kept printing the above text again and again for 60s and then the
test binary times out I think. I'm not sure if it was node printing the
stuff above or if it was a mocha thing. But it was really confusing...

cc @code-asher for thoughts on what was going on.

edit: It was the leaked-handles import in socket.test.ts!!!
Not sure if we should keep it, this was really confusing and misleading.
@nhooyr nhooyr force-pushed the proxy-path-passthrough-0bb9 branch from 5723c7a to c32d8b1 Compare January 20, 2021 07:06
@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

Fixed the branch so the favicon changes aren't part of the diff anymore! Was based on a very old version of master sorry!

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

Happy to leave it in if we can modify the message to indicate it's from that package. Otherwise, it's just confusing if the leak is elsewhere.

Looks like we can't :(

And https://github.com/myndzi/wtfnode is the preferred utility anyway and has much better output. Opening a PR to switch.

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

Also unfortunate and confusing thing about leaked-handles is that it's usage is global as it begins on import instead of letting you call a method to enable. I guess you could require as needed but dynamic requires are a little more annoying. wtfnode just has a global function you call to begin the dumping.

@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

Oo and we can configure the output further if ever needed! https://github.com/myndzi/wtfnode#configuring-logging

nhooyr added a commit to nhooyr/code-server that referenced this pull request Jan 20, 2021
nhooyr added a commit that referenced this pull request Jan 20, 2021
nhooyr added a commit that referenced this pull request Jan 20, 2021
@nhooyr
Copy link
Contributor Author

nhooyr commented Jan 20, 2021

Awesome, thanks for the reviews guys!

@nhooyr nhooyr merged commit 28e98c0 into master Jan 20, 2021
@nhooyr nhooyr deleted the proxy-path-passthrough-0bb9 branch January 20, 2021 07:44
nhooyr added a commit that referenced this pull request Feb 1, 2021
nhooyr added a commit that referenced this pull request Feb 1, 2021
nhooyr added a commit that referenced this pull request Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants